home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5893 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.kreonet.re.kr!usenet
  2. From: jwhahn@cair.kaist.ac.kr (Jung Hahn)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: ???Recursion and strings
  5. Date: Wed, 07 Feb 1996 11:46:36 GMT
  6. Organization: Applied Database Labs, K.A.I.S.T
  7. Message-ID: <3118910a.13494414@news.kreonet.re.kr>
  8. References: <4f44fg$74u@upsidedown.MTS.Net> <31188b9a.12102227@news.kreonet.re.kr>
  9. NNTP-Posting-Host: swine.kaist.ac.kr
  10. X-Newsreader: Forte Agent .99d/32.168
  11.  
  12. On Wed, 07 Feb 1996 11:23:20 GMT, jwhahn@cair.kaist.ac.kr (Jung Hahn)
  13. wrote:
  14.  
  15. >On Mon, 05 Feb 1996 07:26:43 GMT, bwilliam@MTS.Net (George) wrote:
  16. >
  17. >>How do I write a recursive function to print a string  using only
  18. >>printf and %c to print it out.
  19. >>
  20. >>George at bwilliam@MTS.Net
  21. >>
  22. >
  23. >#include <stdio.h>
  24. >
  25. >foo( char *s, int len)
  26. >{
  27. >static int count=0;
  28. >
  29. >    if ( count++ < len) {
  30. >        printf( "%c", *s++);
  31. >        foo( s, len);
  32. >        }
  33. >}
  34. >
  35. >void main( void)
  36. >{
  37. >    char *t = "Hello World\n";
  38. >
  39. >    foo( t, strlen(t));
  40. >}    
  41. >___________
  42. >
  43. >    Name:  Jung w. Hahn
  44. >    Elm:   jwhahn@cair.kaist.ac.kr
  45. >    Phone: 042-869-2959
  46.  
  47.  
  48. Don't start whinning that from the second time you run foo()
  49. it doesn't not work...  It's a time bomb...
  50. I Hope to hell you find out why ... :)
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. ___________
  74.  
  75.     Name:  Jung w. Hahn
  76.     Elm:   jwhahn@cair.kaist.ac.kr
  77.     Phone: 042-869-2959
  78.